<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Simple Two-direction bind</title>
</head>
<body>
    <input type="text" id="textInput">
    输入:<span id="textSpan"></span>
    <script>
        var obj={}
        textInput = document.querySelector('#textInput')
        textSpan = document.querySelector('#textSpan')
        Object.defineProperty(obj,'foo',{
        	set:function (text) {
                textInput.value = text
                textSpan.innerHTML = text
	        }
        })
        textInput.addEventListener('keyup',function (e) {
            obj.foo = e.target.value;
        })
    </script>
</body>
</html>